﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Utils.DatabaseUtils;
using Utils;

namespace DCSLibrary
{
    public class AnalyticsUI
    {
        public int Add(string ReferedURL, string RequestURL, DateTime RequestTime, string IP, string UserAgent, bool IsCrawler, string DomainName)
        {
            try
            {
                return SqlHelper.ExecuteNonQuery(Common.Conn, "Analytics_add", ReferedURL, RequestURL, RequestTime, IP, UserAgent, IsCrawler, DomainName);
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public int Update(int AnylyticsID, string ReferedURL, string RequestURL, DateTime RequestTime, string IP, string UserAgent, bool IsCrawler, string DomainName)
        {
            try
            {
                return SqlHelper.ExecuteNonQuery(Common.Conn, "Analytics_update", AnylyticsID, ReferedURL, RequestURL, RequestTime, IP, UserAgent, IsCrawler, DomainName);
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public DataSet GetAll()
        {
            try
            {
                return SqlHelper.ExecuteDataset(Common.Conn, CommandType.StoredProcedure, "Analytics_getall");
            }
            catch (Exception e)
            {
                return null;
            }
        }

        public DataSet GetByID(int AnylyticsID)
        {
            try
            {
                return SqlHelper.ExecuteDataset(Common.Conn, "Analytics_get", AnylyticsID);
            }
            catch (Exception e)
            {
                return null;
            }
        }

        public int DeleteByID(int AnylyticsID)
        {
            try
            {
                return SqlHelper.ExecuteNonQuery(Common.Conn, "Analytics_delete", AnylyticsID);
            }
            catch (Exception e)
            {
                return -1;
            }
        }
    }
}
